<template>
	<view>
		<view class="container">
			<view class="line-input">
				<text>联系人：</text>
				<input class="uni-input" v-model="lxr" placeholder="请输入联系人" />
			</view>
			<view class="line-input">
				<text>联系电话：</text>
				<input class="uni-input" v-model="lxdh" type="number" maxlength="11" placeholder="请输入手机号" />
			</view>
			<view class="button"><button type="primary" @click="submit">修改</button></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId: "",
				lxr: "",
				lxdh: "",
				sfzh: "",
			};
		},
		onLoad() {},
		onShow() {
			let _this = this;
			this.$api.user({}).then(res => {
				console.log(res,'1111111111111111111111111')
				_this.userId = res.data.data.userId;
				_this.lxr = res.data.data.lxr;
				_this.lxdh = res.data.data.lxdh;
				_this.sfzh = res.data.data.sfzh;
			});
		},
		methods: {
			submit() {
				let _this = this;
				this.$api
					.editProfile({
						userId: _this.userId,
						lxr: _this.lxr,
						lxdh: _this.lxdh,
					})
					.then(res => {
						console.log(res)
						let code = res.data.code;
						if (code == 200) {
							uni.showToast({
								title: '修改成功'
							})
						} else {
							uni.showToast({
								title: '修改失败'
							})
						}
					});
			}
		}
	};
</script>

<style>
	page {
		background-color: #fff;
	}

	.container {
		padding: 20upx;
	}

	.line-input {
		height: 100upx;
		line-height: 100upx;
		display: flex;
		justify-content: space-between;
		border-bottom: solid 1px rgba(0, 0, 0, 0.2);
		padding: 0 20upx;
	}

	.button {
		margin-top: 20px;
	}

	.uni-input {
		text-align: right;
		margin-top: 40upx;
		margin-right: 20upx;
	}
</style>
